// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: exception.hpp 210 2008-08-28 10:10:41Z heavyzheng $
//

#ifndef ZZHENG_XML_DOM_EXCEPTION_HPP_20080716__
#define ZZHENG_XML_DOM_EXCEPTION_HPP_20080716__

#include <zzheng/xml/config.hpp>
#include <exception>
#include <string>

namespace zzheng {
namespace xml {
namespace dom {

    ////////////////////////////////////////////////////////////////////////////////////////////////
    // dom_error
    //

    //! This class represents an error related to XML DOM.
    class dom_error: public std::exception {

    public:

        //! Default constructor.
        explicit dom_error(): what_() {
            // Do nothing.
        }

        explicit dom_error(const char* what): what_(what) {
            // Do nothing.
        }

        virtual ~dom_error() throw() {
            // Do nothing.
        }

        // Use auto-generated copy constructor.
        // Use auto-generated copy assignment.

        virtual const char* what() const throw() {
            return what_.c_str();
        }

    private:

        std::string what_;

    }; // class dom_error

    ////////////////////////////////////////////////////////////////////////////////////////////////
    // bad_dom_operation
    //

    //! This class represents an error of a bad operation on the XML DOM tree.
    class bad_dom_operation: public dom_error {

    public:

        explicit bad_dom_operation(): dom_error() {
            // Do nothing.
        }

        explicit bad_dom_operation(const char* errmsg): dom_error(errmsg) {
            // Do nothing.
        }

        virtual ~bad_dom_operation() throw() {
            // Do nothing.
        }

        // Use auto-generated copy constructor.
        // Use auto-generated copy assignment.

    }; // class bad_dom_operation

    ////////////////////////////////////////////////////////////////////////////////////////////////
    // internal_dom_error
    //

    //! This class represents an error related to the underlying XML library.
    class internal_dom_error: public dom_error {

    public:

        explicit internal_dom_error(): dom_error() {
            // Do nothing.
        }

        explicit internal_dom_error(const char* errmsg): dom_error(errmsg) {
            // Do nothing.
        }

        virtual ~internal_dom_error() throw() {
            // Do nothing.
        }

        // Use auto-generated copy constructor.
        // Use auto-generated copy assignment.

    }; // class internal_dom_error


    ////////////////////////////////////////////////////////////////////////////////////////////////
    // xpath_error
    //

    //! This class represents an error related to XML XPath.
    class xpath_error: public dom_error {

    public:

        explicit xpath_error(): dom_error() {
            // Do nothing.
        }

        explicit xpath_error(const char* errmsg): dom_error(errmsg) {
            // Do nothing.
        }

        virtual ~xpath_error() throw() {
            // Do nothing.
        }

        // Use auto-generated copy constructor.
        // Use auto-generated copy assignment.

    }; // class xpath_error

} // namespace zzheng::xml::dom
} // namespace zzheng::xml
} // namespace zzheng

#endif // ZZHENG_XML_DOM_EXCEPTION_HPP_20080716__



